-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacOS - Implement remaining portions for native ARM64 #15992
Conversation
Why is this in arch64 code? Isn't there already CPU detection for Mac? |
X86 uses CPU registers that are accessible in el0/ring3. Arm uses registers only accessible by the kernel at el1. On x86 builds apple just reports "virtual apple" as the cpu. |
@@ -4,6 +4,10 @@ | |||
#include <thread> | |||
#include <map> | |||
|
|||
#if defined(__APPLE__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this path also be used for FREEBSD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but I have no idea if they use a different path. I have 0 experience with BSD unfortunately, we'll have to rely on their community to help fill in the missing pieces.
{ | ||
static std::mutex mcommit_lock; | ||
std::lock_guard lock(mcommit_lock); | ||
utils::memory_commit(pointer + olda, newa - olda, Prot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, this should somehow be implemented insidr memory_commit
edit: I'll add locks by pointer hash or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware of overlapping regions as well, though I doubt that's a problem in practice.
This operation is pretty quick so I haven't experienced any slowdown. It can also be copied as-is into the memory_commit function.
With these changes, LLVM is now usable on the M-series apple chips natively without going through rosetta. Same caveats as linux apply - not all games will work right now, but most of them should be fine, including AAA titles.